/**
 * author:Administrator
 * date:2016/3/16
 * desc: customer 查询 api
 */

"use strict";
//let CustomerWare = require('../domain/model_query/CustomerWare.js');

let query = require('../infrastructure/query');
//let ware = require('../infrastructure/query').ware;
//let category = require('../infrastructure/query').category;

let api = {};
module.exports = api;
/***********************************************
 * customer的查询行为
 ***********************************************/

api.queryWareByCategoryLocation = function*(cateId, locId, pageIndex, pageSize) {
  return yield query.ware._findByCategoryLocation(cateId, locId, pageIndex, pageSize);
};

api.queryWareByCategory = function*(cateId, locId, pageIndex, pageSize) {
  return yield query.ware._findByCategory(cateId, locId, pageIndex, pageSize);
};

/**
 * category 相关查询
 */
api.allCategory = function*() {
  return yield query.category.findAll();
};

api.topCategory = function*() {
  return yield query.category.findRoot();
};

api.childCategory = function*(pid) {
  return yield query.category.findChild(pid);
};


/**
 * 查询所有 category
 */
api.allLocation = function*() {
  return yield query.location.findAll();
};

api.topLocation = function*() {
  return yield query.location.findRoot();
};

api.childLocation = function*(pid) {
  return yield query.location.findChild(pid);
};

api.allWareOfVendor = function*(vendorId) {
  return yield query.ware.findByVendor(vendorId);
};

api.allShopOfVendor = function*(vendorId) {
  return yield query.shop.findByVendor(vendorId);
};


/**
 * 用户查询优惠券
 */
api.customerQueryCoupon = function*() {

};

/**
 * 用户查询订单
 */
api.customerOrder = function*(customerId) {
  return yield query.order.findByCustomer(customerId);
};

/**
 * 用户查询购物券
 */
api.customerQueryTicket = function*() {
};
